package at.horario.model;

//~--- JDK imports ------------------------------------------------------------


import static javax.persistence.CascadeType.ALL;
import javax.persistence.*;
import static javax.persistence.FetchType.EAGER;
import static javax.persistence.FetchType.LAZY;
import java.io.Serializable;
import java.util.Set;

/**
 * Class description
 *
 * @author AT�
 * @version 1.0, 2007.05.06 at 01:47:04 CAT
 */
@Entity
public class Professor extends GenericObject<Long> implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long professorId;
    @Column(length = 50)
    private String professorNome;
    @Column(length = 9)
    private Integer numHorario;
    @Column(length = 9)
    private Integer numDisciplina;
    @ManyToOne(fetch = EAGER)
    @JoinColumn(name = "disciplinaId")
    private Disciplina disciplina;
    @Column(length = 9)
    private Integer chMax;
    @ManyToOne(fetch = EAGER)
    @JoinColumn(name = "horarioId")
    private Horario horario;
    @Column(length = 9)
    private Integer ch;

    @OneToMany(fetch = LAZY, mappedBy = "professor", cascade = ALL)
    private Set<ProfessorTurma> professorTurmas;
    @OneToMany(fetch = LAZY, mappedBy = "professor", cascade = ALL)
    private Set<ProfessorOcupacao> professorOcupacaos;

    public Professor() {
    }

    public Professor(Integer numHorario, Integer numDisciplina, String professorNome, Disciplina disciplina, Integer chMax, Horario horario) {
        this.professorNome = professorNome;
        this.numDisciplina = numDisciplina;
        this.numHorario = numHorario;
        this.disciplina = disciplina;
        this.chMax = chMax;
        this.horario = horario;
        this.ch = 0;
    }


    public String getProfessorNome() {
        return professorNome;
    }

    public void setProfessorNome(String professorNome) {
        this.professorNome = professorNome;
    }

    public Integer getNumHorario() {
        return numHorario;
    }

    public void setNumHorario(Integer numHorario) {
        this.numHorario = numHorario;
    }

    public Disciplina getDisciplina() {
        return disciplina;
    }

    public void setDisciplina(Disciplina disciplina) {
        this.disciplina = disciplina;
    }

    public Integer getChMax() {
        return chMax;
    }

    public void setChMax(Integer chMax) {
        this.chMax = chMax;
    }

    public Horario getHorario() {
        return horario;
    }

    public void setHorario(Horario horario) {
        this.horario = horario;
    }

    public Integer getCh() {
        return ch;
    }

    public void setCh(Integer ch) {
        this.ch = ch;
    }

    public Long getProfessorId() {
        return professorId;
    }

    public void setProfessorId(Long professorId) {
        this.professorId = professorId;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Professor)) return false;

        Professor professor = (Professor) o;

        return numHorario.equals(professor.numHorario);

    }

    public int hashCode() {
        return numHorario.hashCode();
    }

    public Long getId() {
        return getProfessorId();
    }

    public void addCh(Integer chDisciplinaTurnoGrupo) {
        ch += chDisciplinaTurnoGrupo;
    }

    public Set<ProfessorTurma> getProfessorTurmas() {
        return professorTurmas;
    }

    public void setProfessorTurmas(Set<ProfessorTurma> professorTurmas) {
        this.professorTurmas = professorTurmas;
    }

    public Integer getNumDisciplina() {
        return numDisciplina;
    }

    public void setNumDisciplina(Integer numDisciplina) {
        this.numDisciplina = numDisciplina;
    }

    public String toString() {
        return getDisciplina().getDisciplinaID() + "" + getNumDisciplina();
    }

    public Set<ProfessorOcupacao> getProfessorOcupacaos() {
        return professorOcupacaos;
    }

    public void setProfessorOcupacaos(Set<ProfessorOcupacao> professorOcupacaos) {
        this.professorOcupacaos = professorOcupacaos;
    }
}
